//
//  MycollectionViewCell.m
//  Protect -A
//
//  Created by 付剑英 on 16/6/16.
//  Copyright © 2016年 付剑英. All rights reserved.
//

#import "MycollectionViewCell.h"
#import "baseLabel.h"
#import "baseImageView.h"
#import <Masonry.h>
#import "ModelOfFirst.h"
@interface MycollectionViewCell ()

@property (nonatomic,retain)baseLabel *label;//名字
@property (nonatomic,retain)baseImageView *imageview;//图片
@end

@implementation MycollectionViewCell
//内存管理
-(void)dealloc{
    [self.label release];
    [self.imageview release];
        [super dealloc];
}
//初始化控件
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
}

-(void)create{
    
    self.label = [[baseLabel alloc]init];
    [self.contentView addSubview:self.label];
    
    self.imageview  = [[baseImageView alloc]init];
    [self.contentView addSubview:self.imageview];
    
    
    self.label.backgroundColor = [UIColor redColor];
    self.imageview.backgroundColor = [UIColor yellowColor];


}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
   
    //距离content上 左 下 右距离为10   距离label为10
    
    [self.imageview  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(40);
        make.left.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
       
        make.bottom.mas_equalTo(self.label.mas_top).offset(-5);
    }];
   //距离左右为0 高度是整个content 1/4
   [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
       make.right.bottom.equalTo(self.contentView).offset(-10);
       make.left.mas_equalTo(self.contentView).offset(10);
       make.height.mas_equalTo(self.contentView.frame.size.height/4);
   }];
}
#pragma mark - ------------ 重写model 的set方法 ---------------

- (void)setModel:(ModelOfFirst *)model
{
    if (_model !=model ) {
        [_model release];
        _model = [model retain];
    }
    
}







@end
